package com.atguigu.jucdemo.block;

import ch.qos.logback.core.util.TimeUtil;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

public class blockQueue {
    public static void main(String[] args) throws InterruptedException {
        BlockingQueue blockingQueue = new ArrayBlockingQueue(3);
       /* blockingQueue.add('a');
        blockingQueue.add('b');
        blockingQueue.add('c');

        System.out.println(blockingQueue.element());

        blockingQueue.remove();

        System.out.println(blockingQueue);*/
        /*System.out.println(blockingQueue.offer("a"));
        System.out.println(blockingQueue.offer("b"));
        System.out.println(blockingQueue.offer("c"));
        System.out.println(blockingQueue.offer("d"));*/

        System.out.println(blockingQueue.offer("a"));
        System.out.println(blockingQueue.offer("v"));
        System.out.println(blockingQueue.offer("d"));
        //System.out.println(blockingQueue.offer("a",1,TimeUnit.SECONDS));

        blockingQueue.poll(1,TimeUnit.SECONDS);

        System.out.println(blockingQueue);
    }
}
